package Problem01;

public class CharCounter {
    public static void main(String[] args) {
        String str="ABCD123!@#$%ab";
        int numOfUpper=0;
        int numOfLower=0;
        int numOfNumber=0;
        int others=0;
        for(int i=0;i<str.length();i++){
            char ch=str.charAt(i);
            if((ch>='A')&&(ch<='Z')){
                numOfUpper++;
            }
            else if((ch>='a')&&(ch<='z')){
                numOfLower++;
            }
            else if((ch>='0')&&(ch<='9')){
                numOfNumber++;
            }
            else{
                others++;
            }
        }
        System.out.println("该字符串中大写字母个数为："+numOfUpper);
        System.out.println("该字符串中小写字母的个数为："+numOfLower);
        System.out.println("该字符串中数字的个数为："+numOfNumber);
        System.out.println("其他字符个数为："+others);
    }
}
